package com.softeem.plane.sound;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;

public class SoundPool extends Thread{

	public static final String BG_MUSIC = "game_music.wav";
	public static final String SHOOT = "bullet.wav";
	public static final String BOOM = "enemy0_down.wav";
	
	AudioClip ac;
	
	public SoundPool(String path){
		URL url = null;
		try {
			path = URLDecoder.decode(path,"utf-8");
			url = this.getClass().getResource("/musics/"+path);
			ac = Applet.newAudioClip(url);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public void run() {
		play();
	}
	
	public void play(){
		ac.play();
	}
	
	public void loop(){
		ac.loop();
	}
	

}
